/**
 * 工具类
 * @author VitalYang
 */
function SampUtil()
{
}

SampUtil.prototype = {
    /**
     * 获取当前时间
     * <p>格式为：yyyy-MM-dd HH:mm:SS</p>
     */
    getCurrentTime: function ()
    {
        let myDate = new Date();
        //获取当前年
        let year = myDate.getFullYear();
        //获取当前月
        let month = myDate.getMonth() + 1;
        //获取当前日
        let date = myDate.getDate();
        let h = myDate.getHours();       //获取当前小时数(0-23)
        let m = myDate.getMinutes();     //获取当前分钟数(0-59)
        let s = myDate.getSeconds();

        let now = year + '-' + this.formatCurTime(month) + "-" + this.formatCurTime(date) + " " + this.formatCurTime(
            h) + ':' +
            this.formatCurTime(m) + ":" + this.formatCurTime(s);
        return now;
    },

    /**
     * 格式化时间
     * @param s
     * @return {string}
     */
    formatCurTime: function (s)
    {
        return s < 10 ? '0' + s : s;
    },

    /**
     * 拼接路径，通过泛型参数
     * @param {array}  泛型参数，文件名
     * @return {string} 拼接完成后的路径
     */
    createPath: function ()
    {
        let argLength = arguments.length;
        let tmp = "";
        for (let i = 0; i < argLength; i++)
        {
            tmp += arguments[i] + "/";
        }
        tmp = tmp.substr(0, tmp.length - 1);
        return tmp;
    },

    /**
     * 获取根路径
     * @return {string}
     */
    getRootPath: function ()
    {
        let pathName = window.location.pathname.substring(1);
        let webName = pathName == '' ? '' : pathName.substring(0, pathName.indexOf('/'));
        if (webName == "")
        {
            return window.location.protocol + '//' + window.location.host + "/static";
        }
        else
        {
            return window.location.protocol + '//' + window.location.host + '/' + webName + "/static";
        }
    }
}
